﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aphysoft.Vate
{
#if PRERENDERED
    public static class PreRenderedHelper
    {
        #region Properties

        private static bool active = false;

        /// <summary>
        /// Gets a value indicating whether the PreRendered process is active or not.
        /// </summary>
        public static bool Active
        {
            get { return active; }
        }

        private static int targetFramePerSecond = 0;

        private static string targetLocation = string.Empty;

        private static int frameCounter = 0;

        private static float elapsedTime = float.Epsilon;

        public static float ElapsedTime
        {
            get { return elapsedTime; }
        }

        #endregion

        #region Methods

        public static void Activate(int framePerSecond, string location)
        {
            if (active == false)
            {
                active = true;

                targetFramePerSecond = framePerSecond;
                targetLocation = location;

                // calculate elapsedTime
                elapsedTime = 1.0f / (float)targetFramePerSecond;
            }
        }

        public static void Deactivate()
        {
            if (active)
            {
                active = false;
            }
        }

        public static void Update()
        {


        }

        public static void Draw()
        {
            if (active)
            {
                System.Threading.Thread.Sleep(450);

                frameCounter++;

                if (frameCounter == targetFramePerSecond)
                {
                    frameCounter = 0;
                }
            }
        }

        #endregion
    }
#endif
}
